const config={
  apiUrl: 'https://kdc.5abh.com/',
  post: function (url, data, success,fail=()=>{}) {
    wx.request({
      url: this.apiUrl + url,
      data: data,
      // header: this.apiheader(),
      method: 'post',
      success: function (res) {
        if (res.data.status == 200) {
          const ress = res.data
          success(res.data);
        } else if (res.data.status == 10001) {
          wx.removeStorageSync('token')
          wx.reLaunch({
            url: '/pages/index/index',
          })
        } else{
          if(res.data.message=="token不能为空"){
            wx.removeStorageSync('token')
            wx.reLaunch({
              url: '/pages/index/index',
            })
          } else if (res.data.status == 10002){
            wx.showToast({
              title: '余额不足，即将前往充值',
              icon: 'none'
            })
            setTimeout(()=>{
              wx.navigateTo({
                url: '/pages/money/index',
              })
            },1000)
          }else{
            wx.showToast({
              title: res.data.message,
              icon: 'none'
            });
            fail();
            wx.hideLoading();
          }
        }
      },
      fail: function () {

      }
    })
  },
}
module.exports = config;